package day01.wc

import org.apache.spark.rdd.RDD
import org.apache.spark.{SparkConf, SparkContext}

/**
 * @Author wsl
 * @Description
 */
object Create {
  def main(args: Array[String]): Unit = {
    val conf: SparkConf = new SparkConf().setAppName("rdd").setMaster("local[*]")
    val sc = new SparkContext(conf)

    //集合
    sc.parallelize(List(1, 2, 3, 4), 2).collect().foreach(println)

    //集合
    sc.makeRDD(List(1, 2, 3, 4)).collect().foreach(println)
    sc.makeRDD(List("hello ","world")).collect().foreach(println)
    sc.makeRDD(List("hello world ","world flink")).collect().foreach(println)

    //从外部系统
    sc.textFile("sparkcore/input").collect().foreach(println)

    //本地
    sc.textFile("http://usdp-o3tbdsfp-master2/:8020/input").collect().foreach(println) //hdfs

    //从其他rdd
    sc.makeRDD(List("hello ","world"))
      .flatMap(_.split(" "))
      .collect().foreach(println)

    sc.stop()

  }

}
